<?php

namespace App\Agent\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Shop\Models\ExtensionHistory
 *
 * @property int $id
 * @property string $name
 * @property int $type
 * @property string $version
 * @property string|null $detail
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static \Illuminate\Database\Eloquent\Builder|ExtensionHistory newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|ExtensionHistory newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|ExtensionHistory query()
 * @method static \Illuminate\Database\Eloquent\Builder|ExtensionHistory whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ExtensionHistory whereDetail($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ExtensionHistory whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ExtensionHistory whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ExtensionHistory whereType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ExtensionHistory whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|ExtensionHistory whereVersion($value)
 * @mixin \Eloquent
 */
class ExtensionHistory extends Model
{
    protected $fillable = ['name', 'type', 'version', 'detail'];

    /**
     * {@inheritDoc}
     */
    public function __construct(array $attributes = [])
    {
        $this->init();

        parent::__construct($attributes);
    }

    protected function init()
    {
        $connection = config('agent.database.connection') ?: config('database.default');

        $this->setConnection($connection);

        $this->setTable(config('agent.database.extension_histories_table') ?: 'agent_extension_histories');
    }
}
